Python template

Dirs and stuff

mkdir requirements src docs
touch Makefile requirements/requirements.txt README.md .gitignore

Makefile

# Makefile
#
# Frederico Sales
# <frederico@fredericosales.eng.br>s
#

#
## Settings
#
.PHONY: all \
        help \
        run \
        clean \
        clear \
        install \
        update \
        ignore \
        active \ 
        build


#
## PATH's
#
ARG          := $1
PROJECT      := project_name
SRC          := ~/projects/${PROJECT}/src/${PROJECT}
VENV_BIN_DIR := ~/.virtualenvs/${PROJECT}/bin
ACTIVATE     := ${VENV_BIN_DIR}/activate
PYTHON_BIN   := ${VENV_BIN_DIR}/python
PIP_BIN      := ${VENV_BIN_DIR}/pip
REQUIREMENTS := requirements/requirements.txt
DATE         := `date +"%Y-%m-%d_%H-%M-%S"`

#
## targets
#

#: Do nothing.
all:
    @clear
    @echo ""
    @echo "This target do nothing."
    @echo "Try make help."
    @echo ""


#: Display help and targets.
help:
    @clear
    @echo "Display this help, and targets."
    @echo ""
    @echo "--------------------------------------------------"
    @grep -B1 -E "^[a-zA-Z0-9_-]+:([^\=]|$$)" Makefile \
     | grep -v -- -- \
     | sed 'N;s/\n/###/' \
     | sed -n 's/^#: \(.*\)###\(.*\):.*/\2###\1/p' \
     | column -t  -s '###'s
     @echo "--------------------------------------------------"
    @echo ""


#: Run django application on default port: 8000
run:
    @clear


#: Light cleaning.
clean:
    @clear
    @find . -name "*.pyc" -exec rm -f {} +
    @find . -type d -name "__pycache__" -exec rm -rf {} +
    @find . -type d -name ".DS_Store" -exec rm -rf {} +
    @rm -rf src/kiss/site


#: Heavy clening.
clear:
    @clear
    @find . -name "*.pyc" -exec rm -f {} +
    @find . -type d -name "__pycache__" -exec rm -rf {} +
    @find . -type d -name ".DS_Store" -exec rm -rf {} +
    @find . -name "[0][0]*.py" -exec rm -f {} +


#: Update the project requirements.
update:
    @${PIP_BIN} install -U pip setuptools wheel
    @${PIP_BIN} install -U -r ${REQUIREMENTS}


#: Duh self explanatory...
install:
    @${PIP_BIN} install -U pip setuptools wheel
    @${PIP_BIN} install -r ${REQUIREMENTS}


#: Update gitignore files.
ignore:
    @git rm -r --cached .
    @git add .
    @git commit -m "Update gitignore: ${DATE}."


#: Activate the venv.
active:
    @clear
    @workon ${PROJECT}

#: Build a static site.
build:
    @mkdocs build -f src/kiss/mkdocs.yml

Python header

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

"""
Frederico Sales
<frederico@fredericosales.eng.br>
2024
"""

# imports

if __name__ == "__main__":
    # do something
    print("Hello, there...")

gitignore file

__pycache__
.DS_Store
*.pyc
*~
 .venv
 .env
 .virtualenv
 .pyenv

About

Author